//
//  OrderGoodsTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/11/26.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "OrderGoodsTableViewCell.h"

@implementation OrderGoodsTableViewCell{
    GLGWLabel * storeLabel;
    GLGWLabel * goodslabel;
    GLGWLabel * specLabel;
    GLGWLabel * moneyLabel;
    GLGWLabel * numberlabel;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setSepartionLineWith:lineModel_All];
        //
        storeLabel = [[GLGWLabel alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(15), kHeightProportion_In_iPhoneTriploid(10), KScreenWidth - kWidthProportion_In_iPhoneTriploid(30), kHeightProportion_In_iPhoneTriploid(17)) theFont:SYSTEMFONT(12) theColor:kColor_Rule_Black inSuperView:self];
        NSString *str = @" 小张店铺";
//        storeLabel.backgroundColor = kRandomColor;
        storeLabel.attributedText = [GLGWLabel addImageName:@"icon_dianpu_jinru" theImageFram:CGRectMake(0, -3, kWidthProportion_In_iPhoneTriploid(16), kHeightProportion_In_iPhoneTriploid(14)) theTextString:str atImageIndex:0];

        goodslabel = [[GLGWLabel alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(15), kY_With_View(storeLabel, 10), storeLabel.width, kHeightProportion_In_iPhoneTriploid(20)) theFont:SYSTEMFONT(14) theColor:kColor_Rule_Black inSuperView:self];
        goodslabel.text = @"三级螺纹钢 HRB400E 河钢";
//        goodslabel.backgroundColor = kRandomColor;
        //
        specLabel = [[GLGWLabel alloc] initWithFrame:CGRectMake(goodslabel.x, kY_With_View(goodslabel, 9), goodslabel.width, kHeightProportion_In_iPhoneTriploid(17)) theFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:self];
        specLabel.text = @"φ6*12";
//        specLabel.backgroundColor = kRandomColor;
        //
        moneyLabel = [[GLGWLabel alloc] initWithFrame:CGRectMake(specLabel.x, kY_With_View(specLabel, 10), kWidthProportion_In_iPhoneTriploid(200), kHeightProportion_In_iPhoneTriploid(22)) theFont:SYSTEMFONT(16) theColor:[UIColor colorWithHexString:@"#EC5353"] inSuperView:self];
//        moneyLabel.backgroundColor = kRandomColor;
        moneyLabel.text = @"¥3845";
        //
        numberlabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:self.contentView];
        numberlabel.text= @"35件";
//        numberlabel.backgroundColor = kRandomColor;
        [numberlabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(14));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        
    }
    return self;
}

- (void)refreshCell:(AllOrderDetailListModel *)detailListModel index:(NSIndexPath *)index
{
    NSString *str = [NSString stringWithFormat:@" %@",detailListModel.shopName]; // 店铺名称
    storeLabel.attributedText = [GLGWLabel addImageName:@"icon_dianpu_jinru" theImageFram:CGRectMake(0, -3, kWidthProportion_In_iPhoneTriploid(16), kHeightProportion_In_iPhoneTriploid(14)) theTextString:str atImageIndex:0];

    AllOrderDetailListObjectModel *listObjectModel = detailListModel.orderGoods[index.row];
    goodslabel.text = listObjectModel.productName; // 商品名称
    specLabel.text = listObjectModel.productMaterial; // φ6*12
    numberlabel.text = [NSString stringWithFormat:@"%@件",listObjectModel.goodsNum];
    moneyLabel.text = [NSString stringWithFormat:@"¥%@",listObjectModel.price];
    NSString *moneyLabelStr = [NSString stringWithFormat:@"¥%@",listObjectModel.price];
    NSString *wightStr = [NSString stringWithFormat:@"(%@吨)",listObjectModel.weightCounting];
    NSString *newStr = [NSString stringWithFormat:@"%@ %@",moneyLabelStr,wightStr];
    moneyLabel.attributedText = [GLGWLabel bllChangeStr:newStr changewithStr:wightStr changeColoer:[UIColor colorWithHexString:@"#EC5353"] withFont:SYSTEMFONT(12)];
}
// 去支付页面
- (void)refreshToPayOrderCell:(ToPayOrderDataModel *)payOrderModel index:(NSIndexPath *)index
{
    NSString *str = [NSString stringWithFormat:@" %@", payOrderModel.shopName]; // 店铺名称
    storeLabel.attributedText = [GLGWLabel addImageName:@"icon_dianpu_jinru" theImageFram:CGRectMake(0, -3, kWidthProportion_In_iPhoneTriploid(16), kHeightProportion_In_iPhoneTriploid(14)) theTextString:str atImageIndex:0];
    
    ToPayOrderDataOrderGoodsModel *model = payOrderModel.orderGoods[index.row];
    goodslabel.text = model.productName;
    specLabel.text = model.productMaterial;
    moneyLabel.text = [NSString stringWithFormat:@"¥%@",model.price];
    NSString *monStr;
    if (model.modifyPrice > 0) {
        monStr = [NSString stringWithFormat:@"%@",model.modifyPrice];
    } else {
        monStr = [NSString stringWithFormat:@"%@",model.price];
    }
    NSString *moneyLabelStr = [NSString stringWithFormat:@"¥%@",monStr];
    NSString *wightStr = [NSString stringWithFormat:@"(%@吨)",model.weightCounting];
    NSString *newStr = [NSString stringWithFormat:@"%@ %@",moneyLabelStr,wightStr];
    moneyLabel.attributedText = [GLGWLabel bllChangeStr:newStr changewithStr:wightStr changeColoer:[UIColor colorWithHexString:@"#EC5353"] withFont:SYSTEMFONT(12)];
    numberlabel.text = [NSString stringWithFormat:@"%ld件",model.goodsNum];
}

@end
